import numpy as np
import pandas as pd                 #导入pandas
import matplotlib.pyplot as plt

# 箱线图
# x = [1,2,3,5]   				#数据集
# plt.boxplot(x,vert = False)    				#水平显示箱线图
# # plt.boxplot(x)    				#垂直显示箱线图
#
# plt.show()

x = [1,2,3,5]   				#数据集
y = [4,3,7,9]
z= [2,4,8]
plt.boxplot((x,y,z),labels=('x','y','z'))
plt.show()

# dt = pd.DataFrame({             #用字典去建立数据表，第一列的列名a,列值是[1,2,3,4,5];第二列的列名是b，列值是 [5, 6, 7, 8]，以此类推
#     'a': [1, 2, 3, 4],
#     'b': [5, 6, 7, 8],
#     'c': [9, 10, 11, 12],
#     'd': [13, 14, 15, 16]
# })
# # 用matplotlib来画出箱型图
# plt.boxplot(x=dt.values,labels=dt.columns,whis=1.5) #columns列索引，values所有数值
# plt.show()


# plt.figure()

# fig = plt.figure()
# ax = fig.add_subplot(211)
# ax.set(xlim=[0.5, 4.5], ylim=[-2, 8], title='An Example Axes',
#        ylabel='Y-Axis', xlabel='X-Axis')
#
# bx = fig.add_subplot(212)
# bx.set(xlim=[0.5, 4.5], ylim=[-2, 8], title='An Example Axes',
#        ylabel='Y-Axis', xlabel='X-Axis')
# plt.show()
#
# fig, axes = plt.subplots(nrows=2, ncols=2)
# axes[0,0].set(title='Upper Left')
# axes[0,1].set(title='Upper Right')
# axes[1,0].set(title='Lower Left')
# axes[1,1].set(title='Lower Right')
# plt.show()
#
# plt.plot([1, 2, 3, 4], [10, 20, 25, 30], color='lightblue', linewidth=3)
# plt.xlim(0.5, 4.5)
# plt.show()
#
# x = np.arange(10)
# y = np.random.randn(10)
# plt.scatter(x, y, color='red', marker='+')
# plt.show()


# # 条形图
# np.random.seed(19680801)
#
# n_bins = 10
# x = np.random.randn(1000, 3)
#
# fig, axes = plt.subplots(nrows=2, ncols=2)
# ax0, ax1, ax2, ax3 = axes.flatten()
#
# colors = ['red', 'tan', 'lime']
# ax0.hist(x, n_bins, density=True, histtype='bar', color=colors, label=colors)
# ax0.legend(prop={'size': 10})
# ax0.set_title('bars with legend')
#
# ax1.hist(x, n_bins, density=True, histtype='barstacked')
# ax1.set_title('stacked bar')
#
# ax2.hist(x,  histtype='barstacked', rwidth=0.9)
#
# ax3.hist(x[:, 0], rwidth=0.9)
# ax3.set_title('different sample sizes')
#
# fig.tight_layout()
# plt.show()


#
# # def f(t):
# #     return np.exp(-t) * np.cos(2 * np.pi * t)
# #
# #
# # a = np.arange(0.0, 5.0, 0.02)
# # plt.subplot(211)
# # plt.plot(a, f(a))
# # plt.subplot(2, 1, 2)
# # plt.plot(a, np.cos(2 * np.pi * a), 'r--')
# # plt.savefig('test', dpi=600)
# # plt.show()
#
#
# a = np.arange(0.0, 5.0, 0.02)
# plt.plot(a, np.cos(2 * np.pi * a), 'r--')
# plt.xlabel('纵轴： 振幅', fontproperties='SimHei', fontsize=20, color='green')
# plt.ylabel('横轴： 时间', fontproperties='SimHei', fontsize=20)
# plt.title(r'正弦波实例$y=cos(2\pi x)$', fontproperties='SimHei', fontsize=25)
# plt.annotate(r'$\mu=100$', xy=(2, 1), xytext=(3, 1.5),
#              arrowprops=dict(facecolor='black', shrink=0.1, width=2))
# plt.axis([-1, 6, -2, 2])
# plt.grid()
# # plt.savefig('test', dpi=600)
# plt.show()

# encoding:utf-8
# '''
# Created on 2015年9月11日
# @author: ZHOUMEIXU204
# '''
#
# # pylab 是 matplotlib 面向对象绘图库的一个接口。它的语法和 Matlab 十分相近
# import pandas as pd
# from ggplot import *
# import numpy as np
# import matplotlib.pyplot as plt
#
# df = pd.DataFrame(np.random.randn(1000, 4), columns=list('ABCD'))
# df = df.cumsum()
# print(plt.figure())
# print(df.plot())
# print(plt.show())
#
# # print(ggplot(df,aes(x='A',y='B'))+geom_point())
#
# # 画简单的图形
# from pylab import *
#
# x = np.linspace(-np.pi, np.pi, 256, endpoint=True)
# c, s = np.cos(x), np.sin(x)
# plot(x, c, color="blue", linewidth=2.5, linestyle="-", label="cosine")  # label用于标签显示问题
# plot(x, s, color="red", linewidth=2.5, linestyle="-", label="sine")
# show()
#
# # 散点图
# from pylab import *
#
# n = 1024
# X = np.random.normal(0, 1, n)
# Y = np.random.normal(0, 1, n)
# scatter(X, Y)
# show()
#
# # 条形图
#
# from pylab import *
#
# n = 12
# X = np.arange(n)
# Y1 = (1 - X / float(n)) * np.random.uniform(0.5, 1.0, n)
# Y2 = (1 - X / float(n)) * np.random.uniform(0.5, 1.0, n)
# bar(X, +Y1, facecolor='#9999ff', edgecolor='white')
# bar(X, -Y2, facecolor='#ff9999', edgecolor='white')
# for x, y in zip(X, Y1):
#     text(x + 0.4, y + 0.05, '%.2f' % y, ha='center', va='bottom')
# ylim(-1.25, +1.25)
# show()
#
# # 饼图
# from pylab import *
#
# n = 20
# Z = np.random.uniform(0, 1, n)
# pie(Z), show()
#
# # 画三维图
# import numpy as np
# from mpl_toolkits.mplot3d import Axes3D
# from pylab import *
#
# fig = figure()
# ax = Axes3D(fig)
# x = np.arange(-4, 4, 0.1)
# y = np.arange(-4, 4, 0.1)
# x, y = np.meshgrid(x, y)
# R = np.sqrt(x ** 2 + y ** 2)
# z = np.sin(R)
# ax.plot_surface(x, y, z, rstride=1, cstride=1, cmap='hot')
# show()
#
# # 用于图像显示的问题
#
# import matplotlib.pyplot as plt
# import pandas as pd
#
# weights_dataframe = pd.DataFrame()
# plt.figure()
# plt.plot(weights_dataframe.weights_ij, weights_dataframe.weights_x1, label='weights_x1')
# plt.plot(weights_dataframe.weights_ij, weights_dataframe.weights_x0, label='weights_x0')
# plt.plot(weights_dataframe.weights_ij, weights_dataframe.weights_x2, label='weights_x2')
# plt.legend(loc='upper right')  # 用于标签显示问题
# plt.xlabel(u"迭代次数", fontproperties='SimHei')
# plt.ylabel(u"参数变化", fontproperties='SimHei')
# plt.title(u"迭代次数显示", fontproperties='SimHei')  # fontproperties='SimHei'  用于可以显示中文
# plt.show()


import matplotlib.pyplot as plt
import numpy as np

# def hello(yumo): # 测试打印函数
#     print(yumo)
#
# def main():     # 主函数
#     print('this is main function!')
#
# hello('hello yumoz this is your palce!')
# if __name__ == '__main__':
#     main()

# xpoints = np.array([0, 6])
# ypoints = np.array([0, 100])
#
# plt.plot(xpoints, ypoints)
# plt.show()
#
#
# x = np.arange(0,4*np.pi,0.1)   # start,stop,step
# y = np.sin(x)
# z = np.cos(x)
# plt.plot(x,y,x,z)
# plt.show()

